package com.mzy.linear_struct.hot100.双指针;

/**
 * @Author: mizy3
 * @Date: 2024/08/11/下午2:58
 * @Description:
 */
public class Pro11盛水最多的容器 {
    private int maxArea(int[] height) {
        if (height == null || height.length == 0) return 0;
        int l = 0, r = height.length - 1;
        int ans = Integer.MIN_VALUE;
        int h = 0;
        int w = 0;
        while (l < r) {
            if (height[l] < height[r]) {
                h = height[l];
                w = r - l;
                l++;
            }else {
                h = height[r];
                w = r - l;
                r--;
            }
            ans = Math.max(ans, h * w);
        }


        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Pro11盛水最多的容器().maxArea(new int[]{1, 8, 6, 2, 5, 4, 8, 3, 7}));
    }



}























